//
//  NSString+GenerateTradeNO.m
//  ZYOils
//
//  Created by WANGGNIT on 2019/9/3.
//  Copyright © 2019 WANGGNIT. All rights reserved.
//

#import "NSString+GenerateTradeNO.h"

@implementation NSString (GenerateTradeNO)

//产生随机字符串
+ (NSString *)generateTradeNO
{
    static int kNumber = 6;
    
    NSString *sourceStr = @"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    
    NSMutableString *resultStr = [[NSMutableString alloc] init];
    srand(time(0));
    for (int i = 0; i < kNumber; i++)
    {
        unsigned index = rand() % [sourceStr length];
        NSString *oneStr = [sourceStr substringWithRange:NSMakeRange(index, 1)];
        [resultStr appendString:oneStr];
    }
    return resultStr;
}

@end
